<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core"    
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:t="http://myfaces.apache.org/tomahawk">
    <h:head>
    	<h:outputStylesheet library="css" name="table.css" />
        <title>
            <h:outputText value="#{startPageBean.name}"/>
        </title>
        <f:view>
            <f:metadata>
               <f:viewParam name="deletedID" value="#{startPageBean.deletedId}" />
            </f:metadata>
        </f:view>
    </h:head>
    <h:body>
        <t:htmlTag value="br" />
        <h:outputLabel value="#{startPageBean.deletedId}" />
        <t:htmlTag value="br" />
        <h:form enctype="multipart/form-data">
            <h:panelGrid columns="4" border="1">
                <f:facet name="header">
                    <h:outputText value="Add new session"/>
                </f:facet>
                
                <h:outputLabel value="Session name" />
                <h:inputText id="sessionName" value="#{startPageBean.sessionName}"/>
                <t:inputFileUpload id="file" value="#{startPageBean.uploadedFile}" required="true"  />
                <h:commandButton value="Upload" action="#{startPageBean.submit}" />
                
                <f:facet for="file" name="footer">
                    <h:messages id="file_msg"/>
                </f:facet>
            </h:panelGrid>
        </h:form>
        
        <t:htmlTag value="br" />
        
        <h:dataTable id="dataTable" value="#{startPageBean.sessionList}" var="s" 
    			styleClass="order-table"
    			headerClass="order-table-header"
    			rowClasses="order-table-odd-row,order-table-even-row">
            <h:column>
                <f:facet name="header">
                    <h:outputText value="ID" />
                </f:facet>
                <h:outputText value="#{s.id}" />
            </h:column>
            <h:column>
                <f:facet name="header" >
                    <h:outputText value="Session Name" />
                </f:facet>
                <h:form>
                    <h:commandLink value="#{s.name}" 
                                   action="#{startPageBean.gotoViewer(s)}">
                        <f:param name="currentID" value="#{s.id}" />
                    </h:commandLink>
                    <t:htmlTag value="br" />
                    <h:link value="#{s.name}" outcome="permalink">
                        <f:param name="currentID" value="#{s.id}" />
                    </h:link>
                </h:form>
            </h:column>
            <h:column>
                <f:facet name="header">
                    <h:outputText value="Date" />
                </f:facet>
    		<h:outputText value="#{s.date}" />
            </h:column>
            <h:column>
                <f:facet name="header">
                    <h:outputText value="File name" />
                </f:facet>
                <h:outputText value="#{s.filename}" />
            </h:column>
            <h:column>
                <f:facet name="header">
                    <h:outputText value="Size" />
                </f:facet>
    		<h:outputText value="#{s.size}" />
            </h:column>
            <h:column>
                <f:facet name="header">
                    <h:outputText value="Actions" />
                </f:facet>

                <h:form>
                    <h:commandLink title="delete row" 
                                   action="#{startPageBean.deleteRow(s)}">
                        <f:param name="currentID" value="#{s.id}" />
                        <h:graphicImage library="images" name="cmd_delete.png" />
                    </h:commandLink>
                    <h:commandLink title="download log" 
                                   action="#{startPageBean.createAndDownloadLog(s)}" >
                        <h:graphicImage library="images" name="cmd_download.png" />
                    </h:commandLink>
                </h:form>
            </h:column>
        </h:dataTable>
    </h:body>
</html>

